package
{
	import flash.display.Sprite;
	import flash.display.StageAlign;
	import flash.display.StageAspectRatio;
	import flash.display.StageDisplayState;
	import flash.display.StageOrientation;
	import flash.display.StageScaleMode;
	import flash.events.Event;
	import flash.geom.Rectangle;
	
	import net.hires.debug.Stats;
	
	import starling.core.Starling;
	
	[SWF(frameRate="80", backgroundColor="#003366")]
	public class BunkysAijou extends Sprite
	{
		public static var mystarling:Starling;
		//public static var debugSprite:flash.display.Sprite;
		public var _isMobile:Boolean;
		
		public function BunkysAijou(isMobile:Boolean = true)
		{
			super();
			_isMobile = isMobile;
			this.addEventListener(Event.ADDED_TO_STAGE, onAdded);			
		}
		
		protected function onAdded(event:Event):void
		{			
			//addChild(new Stats());			
			// support autoOrients
			stage.align = StageAlign.TOP_LEFT;
			stage.scaleMode = StageScaleMode.NO_SCALE;											
			//create Starling instance and add instance of class Game
			//to the root of the Starling display list
			var width:uint = stage.fullScreenWidth;		
			var height:uint = stage.fullScreenHeight;
			if(!_isMobile)
			{
				height = stage.fullScreenWidth > stage.fullScreenHeight ? stage.stageHeight : stage.fullScreenWidth;
				width = stage.fullScreenWidth > stage.fullScreenHeight ? stage.stageWidth : stage.fullScreenHeight;				
			}
			mystarling = new Starling(Game, stage, new Rectangle(0,0,width,height));
			mystarling.stage.stageWidth = 640;
			mystarling.stage.stageHeight = 480;
			trace(Starling.current.contentScaleFactor);
			mystarling.showStats = false;
			mystarling.start();
			stage.stage3Ds[0].addEventListener(Event.CONTEXT3D_CREATE, onContextCreated);
		}
		
		private function onContextCreated(e:Event):void
		{
			//debug mode
			//debugSprite=new Sprite();
			//addChild(debugSprite);
		} 
		
	}
}